/** 项目管理路由 */
import Layout from '@/views/layout/managerLayout'

/**
 * 系统管理里的 客户管理
 */
const systemCustomerAuth = {
  requiresAuth: true,
  index: 1,
  type: 'manage',
  subType: 'crm'
}

const systemCustomerRouter = {
  name: 'system-customer',
  path: 'system-customer',
  meta: {
    title: '客户管理',
    icon: 'customer',
    ...systemCustomerAuth
  },
  children: [{
    path: 'custom-field',
    component: () => import('@/views/SystemManagement/SystemCustomer/customField'),
    meta: {
      title: '自定义字段设置',
      ...systemCustomerAuth
    }
  }, {
    path: 'customer',
    component: () => import('@/views/SystemManagement/SystemCustomer/customer'),
    meta: {
      title: '客户公海规则设置',
      ...systemCustomerAuth
    }
  }, {
    path: 'biz-param',
    component: () => import('@/views/SystemManagement/SystemCustomer/bizParam'),
    meta: {
      title: '业务参数设置',
      ...systemCustomerAuth
    }
  }, {
    path: 'biz-goals',
    component: () => import('@/views/SystemManagement/SystemCustomer/bizGoals'),
    meta: {
      title: '业绩目标设置',
      ...systemCustomerAuth
    }
  }]
}

/**
 * 不包含children的路由
 */
const systemOtherRouter = {
  path: '/manager',
  component: Layout,
  redirect: '/manager/systemconfig',
  name: 'manager',
  hidden: true,
  meta: {
    requiresAuth: true,
    title: '系统管理',
    index: 0,
    type: 'manage'
  },
  children: [{
    name: 'systemconfig',
    path: 'systemconfig', // 系统配置
    component: () => import('@/views/SystemManagement/SystemConfig/index'),
    meta: {
      requiresAuth: true,
      title: '系统配置',
      icon: 'systemconfig',
      index: 1,
      type: 'manage',
      subType: 'system'
    }
  },
  {
    name: 'employee-dep',
    path: 'employee-dep', // 员工与部门管理
    component: () => import('@/views/SystemManagement/SystemEmployee/EmployeeDepManagement'),
    meta: {
      requiresAuth: true,
      title: '员工与部门管理',
      icon: 'department',
      index: 1,
      type: 'manage',
      subType: 'user'
    }
  },
  {
    name: 'role-authorization',
    path: 'role-authorization',
    component: () => import('@/views/SystemManagement/RoleAuthorization'),
    meta: {
      requiresAuth: true,
      title: '角色权限管理',
      icon: 'contacts',
      index: 1,
      type: 'manage',
      subType: 'permission'
    }
  },
  {
    name: 'system-examine',
    path: 'system-examine',
    component: () => import('@/views/SystemManagement/SystemExamine/SystemExamine'),
    meta: {
      requiresAuth: true,
      title: '审批流程管理',
      icon: 'examine',
      index: 1,
      type: 'manage',
      subType: 'examineFlow'
    }
  },
  {
    name: 'system-workbench',
    path: 'system-workbench', // 工作台
    component: () => import('@/views/SystemManagement/SystemWorkbench'),
    meta: {
      requiresAuth: true,
      title: '工作台',
      icon: 'workbench',
      index: 1,
      type: 'manage',
      subType: 'oa'
    }
  },
  {
    name: 'project',
    path: 'project', // 项目管理
    component: () => import('@/views/SystemManagement/project'),
    meta: {
      requiresAuth: true,
      title: '项目管理',
      icon: 'project',
      index: 1,
      type: 'manage',
      subType: 'work'
    }
  },
  {
    name: 'matter',
    path: 'matter', // 办件事项
    component: () => import('@/views/SystemManagement/matter'),
    meta: {
      requiresAuth: true,
      title: '办件事项',
      icon: 'product',
      index: 1,
      type: 'manage',
      subType: 'system'
    }
  },
  {
    name: 'division',
    path: 'division', // 事业部管理
    component: () => import('@/views/SystemManagement/division'),
    meta: {
      requiresAuth: true,
      title: '事业部管理',
      icon: 'set',
      index: 1,
      type: 'manage',
      subType: 'system'
    }
  },
  {
    name: 'divisicostTypeon',
    path: 'costType', // 核定成本类型管理
    component: () => import('@/views/SystemManagement/costType'),
    meta: {
      requiresAuth: true,
      title: '核定成本类型',
      icon: 'money',
      index: 1,
      type: 'manage',
      subType: 'system'
    }
  },
  {
    name: 'expence-class',
    path: 'expence-class', // 费用类别管理
    component: () => import('@/views/SystemManagement/expenceClass'),
    meta: {
      requiresAuth: true,
      title: '费用类别管理',
      icon: 'tag',
      index: 1,
      type: 'manage',
      subType: 'system'
    }
  }
  ]
}

const handlefieldRouter = {
  name: 'handlefield',
  path: 'custom-field/handlefield/:type/:id', // type customer contacts business contract money
  component: () => import('@/views/SystemManagement/SystemCustomer/HandleField'),
  meta: {
    changeMenu: false, // 跳转不更改路径
    menuSelct: 'system-customer',
    menuIndex: 'custom-field'
  },
  hidden: true
}

export const managerRouter = {
  path: '/manager',
  component: Layout,
  redirect: '/manager/systemconfig',
  name: 'manager',
  hidden: true,
  meta: {
    requiresAuth: true,
    title: '系统管理',
    index: 0,
    type: 'manage'
  },
  children: [
    ...systemOtherRouter.children,
    ...systemCustomerRouter.children,
    handlefieldRouter
  ]
}

export const managerRouterMenu = [
  ...systemOtherRouter.children,
  systemCustomerRouter
]
